/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListTaller1PDSData {
	private static final int ROW_COUNT = 100;
	
	public void listTestData() throws PersistentException {
		System.out.println("Listing Pacient...");
		com.pancho.Pacient[] companchoPacients = com.pancho.PacientDAO.listPacientByQuery(null, null);
		int length = Math.min(companchoPacients.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoPacients[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing User...");
		com.pancho.User[] companchoUsers = com.pancho.UserDAO.listUserByQuery(null, null);
		length = Math.min(companchoUsers.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoUsers[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Doctor...");
		com.pancho.Doctor[] companchoDoctors = com.pancho.DoctorDAO.listDoctorByQuery(null, null);
		length = Math.min(companchoDoctors.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoDoctors[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing BabyMonitor...");
		com.pancho.BabyMonitor[] companchoBabyMonitors = com.pancho.BabyMonitorDAO.listBabyMonitorByQuery(null, null);
		length = Math.min(companchoBabyMonitors.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoBabyMonitors[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Solution...");
		com.pancho.Solution[] companchoSolutions = com.pancho.SolutionDAO.listSolutionByQuery(null, null);
		length = Math.min(companchoSolutions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoSolutions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Diagnose...");
		com.pancho.Diagnose[] companchoDiagnoses = com.pancho.DiagnoseDAO.listDiagnoseByQuery(null, null);
		length = Math.min(companchoDiagnoses.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoDiagnoses[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Response...");
		com.pancho.Response[] companchoResponses = com.pancho.ResponseDAO.listResponseByQuery(null, null);
		length = Math.min(companchoResponses.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoResponses[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Question...");
		com.pancho.Question[] companchoQuestions = com.pancho.QuestionDAO.listQuestionByQuery(null, null);
		length = Math.min(companchoQuestions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoQuestions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing QuestForm...");
		com.pancho.QuestForm[] companchoQuestForms = com.pancho.QuestFormDAO.listQuestFormByQuery(null, null);
		length = Math.min(companchoQuestForms.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(companchoQuestForms[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Pacient by Criteria...");
		com.pancho.PacientCriteria pacientCriteria = new com.pancho.PacientCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//pacientCriteria.idPaciente.eq();
		pacientCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Pacient[] companchoPacients = pacientCriteria.listPacient();
		int length =companchoPacients== null ? 0 : Math.min(companchoPacients.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoPacients[i]);
		}
		System.out.println(length + " Pacient record(s) retrieved."); 
		
		System.out.println("Listing User by Criteria...");
		com.pancho.UserCriteria userCriteria = new com.pancho.UserCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//userCriteria.codUser.eq();
		userCriteria.setMaxResults(ROW_COUNT);
		com.pancho.User[] companchoUsers = userCriteria.listUser();
		length =companchoUsers== null ? 0 : Math.min(companchoUsers.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoUsers[i]);
		}
		System.out.println(length + " User record(s) retrieved."); 
		
		System.out.println("Listing Doctor by Criteria...");
		com.pancho.DoctorCriteria doctorCriteria = new com.pancho.DoctorCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//doctorCriteria.idDoctor.eq();
		doctorCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Doctor[] companchoDoctors = doctorCriteria.listDoctor();
		length =companchoDoctors== null ? 0 : Math.min(companchoDoctors.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoDoctors[i]);
		}
		System.out.println(length + " Doctor record(s) retrieved."); 
		
		System.out.println("Listing BabyMonitor by Criteria...");
		com.pancho.BabyMonitorCriteria babyMonitorCriteria = new com.pancho.BabyMonitorCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//babyMonitorCriteria.codSystem.eq();
		babyMonitorCriteria.setMaxResults(ROW_COUNT);
		com.pancho.BabyMonitor[] companchoBabyMonitors = babyMonitorCriteria.listBabyMonitor();
		length =companchoBabyMonitors== null ? 0 : Math.min(companchoBabyMonitors.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoBabyMonitors[i]);
		}
		System.out.println(length + " BabyMonitor record(s) retrieved."); 
		
		System.out.println("Listing Solution by Criteria...");
		com.pancho.SolutionCriteria solutionCriteria = new com.pancho.SolutionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//solutionCriteria.idSolution.eq();
		solutionCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Solution[] companchoSolutions = solutionCriteria.listSolution();
		length =companchoSolutions== null ? 0 : Math.min(companchoSolutions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoSolutions[i]);
		}
		System.out.println(length + " Solution record(s) retrieved."); 
		
		System.out.println("Listing Diagnose by Criteria...");
		com.pancho.DiagnoseCriteria diagnoseCriteria = new com.pancho.DiagnoseCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//diagnoseCriteria.idDiag.eq();
		diagnoseCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Diagnose[] companchoDiagnoses = diagnoseCriteria.listDiagnose();
		length =companchoDiagnoses== null ? 0 : Math.min(companchoDiagnoses.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoDiagnoses[i]);
		}
		System.out.println(length + " Diagnose record(s) retrieved."); 
		
		System.out.println("Listing Response by Criteria...");
		com.pancho.ResponseCriteria responseCriteria = new com.pancho.ResponseCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//responseCriteria.idResponse.eq();
		responseCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Response[] companchoResponses = responseCriteria.listResponse();
		length =companchoResponses== null ? 0 : Math.min(companchoResponses.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoResponses[i]);
		}
		System.out.println(length + " Response record(s) retrieved."); 
		
		System.out.println("Listing Question by Criteria...");
		com.pancho.QuestionCriteria questionCriteria = new com.pancho.QuestionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//questionCriteria.idQuest.eq();
		questionCriteria.setMaxResults(ROW_COUNT);
		com.pancho.Question[] companchoQuestions = questionCriteria.listQuestion();
		length =companchoQuestions== null ? 0 : Math.min(companchoQuestions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoQuestions[i]);
		}
		System.out.println(length + " Question record(s) retrieved."); 
		
		System.out.println("Listing QuestForm by Criteria...");
		com.pancho.QuestFormCriteria questFormCriteria = new com.pancho.QuestFormCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//questFormCriteria.idQuestForm.eq();
		questFormCriteria.setMaxResults(ROW_COUNT);
		com.pancho.QuestForm[] companchoQuestForms = questFormCriteria.listQuestForm();
		length =companchoQuestForms== null ? 0 : Math.min(companchoQuestForms.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(companchoQuestForms[i]);
		}
		System.out.println(length + " QuestForm record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListTaller1PDSData listTaller1PDSData = new ListTaller1PDSData();
			try {
				listTaller1PDSData.listTestData();
				//listTaller1PDSData.listByCriteria();
			}
			finally {
				com.pancho.Taller1PDSPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
